<form id="form-practice" action="/invitation/practice_${behaviour}" method="POST" >
    <input type="hidden" name="CSRFToken" value="${CSRFToken!""}"/>
    <input type="hidden" name="mobile" value="${mobile}" />
    <table width="100%" class="dj-form-base">
        <colgroup>
            <col width="200">
            <col width="*">
        </colgroup>
        <tbody>
        <tr>
            <th><em>*</em>公司名称:</th>
            <td class="input matchbox-wrap" colspan="3">
                <input type="text" autocomplete="off" id="employer-input" class="text J_check" name="corpName" reg="^.{2,40}$" maxlength="40" value="${(practice.corpName)!}"> &nbsp;&nbsp;
                <div style="display:none;" class="error">请填写正确的公司名称</div>
            </td>
            <script type="text/javascript">
                $('#employer-input').matchbox({query: 'http://job.dajie.com/ajax/corp?s={1}', strict: false, statistic: true});
            </script>
        </tr> 
        <tr>
            <th><em>*</em>职位名称:</th>
            <td class="input" colspan="3">
                <input type="text" name="position" value="${(practice.position)!}" class="text J_check" id="position-input" reg="^.{2,15}$" maxlength="15">
                <div style="display:none;" class="error">请填写正确的职位名称</div>
            </td>
        </tr>
        <tr>
            <th>所属行业:</th>
            <td class="input" colspan="3">
                <input type="text" value="<#if (practice.positionIndustry)?? && dictMap.DICT_POSITION_INDUSTRY.map.get(practice.positionIndustry)??>${dictMap.DICT_POSITION_INDUSTRY.map.get(practice.positionIndustry).name!}</#if>" reg="^.+$" readonly="yes" class="text select-beauty" id="industry-input">
                <input type="hidden" value="${(practice.positionIndustry)!}" name="positionIndustry" id="industry-hidden">
                <a href="javascript:void(0);" id="industry-link" class="arrowhandler" style="display:none">打开</a>
                <div style="display: none; " class="error">请选择所属行业</div>
            </td>
            <script type="text/javascript">
                $('#industry-link').pickpadRadio({title: '请选择行业类别', width: 700,oncomplete:function(){

                }});
            </script>
        </tr>
        <tr>
            <th><em>*</em>职位类别:</th>
            <td class="input" colspan="3">
                <input type="text" value="<#if (practice.positionFunction)?? && dictMap.DICT_POSITION_FUNCTION.map.get(practice.positionFunction)??>${dictMap.DICT_POSITION_FUNCTION.map.get(practice.positionFunction).name!}</#if>" id="profession-input" reg="^.+$" class="text J_check select-beauty" >
                <input type="hidden" name="positionFunction" value="${(practice.positionFunction)!}" id="profession-hidden">
                <a href="javascript:void(0);" id="profession-link" style="display:none" class="arrowhandler">打开</a>
                <div style="display: none; " class="error">请选择职位类别</div>
            </td>
            <script type="text/javascript">
                $('#profession-link').pickpadRadio({title: '请选择职位类别', width: 700,oncomplete:function(){
                }});
            </script>
        </tr>
        <#if !intership??>
        <tr>
            <th><em>*</em>职位级别:</th>
            <td class="input" colspan="3">
                <select name="positionExperience" reg="^[^0]" class="select J_check public-select" >
                    <option value="">请选择</option>
                    <#list dictMap.DICT_POSITION_EXPERIENCE.data as item>
                        <option value="${item.id?c}"<#if (practice.positionExperience)?? && practice.positionExperience==item.id>selected</#if>>${item.name}</option>
                    </#list>
                </select>
                <div style="display: none; " class="error">请选择职位级别</div>
            </td>
        </tr>
        <#else >
            <input type="hidden" name="positionExperience" value="1">
        </#if>
        <tr>
            <th>在职时间:</th>
            <#if (practice.endDate)?? && practice.endDate?string('yyyy-MM-dd') = '2030-01-01'>
                <#assign endYear = ''/>
                <#assign endMonth = ''/>
                <#assign checked= "checked"/>
            <#else>
                <#assign endYear = (practice.endDate?string('yyyy'))!""/>
                <#assign endMonth = (practice.endDate?string('MM'))!""/>
            </#if>
            <td class="input" colspan="3">
                <input type="text" reg="fun:$.formValidateFn.time,work,td" class="text year" id="work-startdate-year" name="start" maxlength="4" value="${(practice.startDate?string('yyyy'))!}">
                <span class="input">年</span>
                <input type="text" class="text month" id="startdate-month" name="start" maxlength="2" value="${(practice.startDate?string('MM'))!}">
                <span class="input">月&nbsp;至</span>
                <input type="text" class="text year" id="enddate-year" name="end" maxlength="4" value="${(endYear)!""}" <#if checked??>disabled </#if>>
                <span class="input">年</span>
                <input type="text" class="text month" id="enddate-month" name="end" maxlength="2" value="${(endMonth)!""}" <#if checked??>disabled </#if>>
                <span class="input">月</span>
                <input type="checkbox" class="checkbox radio" name="withoutEnd" value="present" id="enddate-present-checkbox" <#if checked??>checked </#if>>
                <span class="input f12" for="enddate-present-checkbox">至今</span>
                <div style="display: none; " class="error">请填写正确的在职时间</div>
            </td>
        </tr>
         
        <tr>
            <th style="padding-bottom:10px;" class="label">工作描述:</th>
            <td style="padding-bottom:10px;" class="input textarea-box" colspan="3">
                <textarea blanksubmit="true" reg="^.{0,400}$" name="descr" blankvalue="描述工作职责范围及成绩等（限400字）" blankclass="g9"  class="textarea-con J_check g9" style="width:373px;height:60px;font-size:12px" maxnum="400"><#if (practice.descr)??>${practice.descr}</#if></textarea>
                <p class="textarea-check-tip"><span class="J_lastNum g9"><span>0</span>/400</span></p>
            </td>
        </tr>
        <tr>
            <th>&nbsp;</th>
            <td class="input button" colspan="3">
                <a href="javascript:void(0);" class="fresh practiceValidate margin" id="J_practiceSubmit" <#if intership??>itemtype="intern" <#else>itemtype="practice"</#if>><span>保存</span></a><a href="javascript:void(0);" class="normal J_cancel" <#if intership??>itemtype="intern" <#else>itemtype="practice"</#if>><span>取消</span></a>
            </td>
        </tr>
        </tbody>
    </table>

    <input type="hidden" name="method" value="do"/>
    <input type="hidden" name="id" value="${(practice.id)!""}">
    <input type="hidden" name="startDate" value="" id="id-startDate">
    <input type="hidden" name="endDate" value="" id="id-endDate">
</form>

    <div id="industry-dialog" style="display:none;">
    <#assign industryType="radio"/>
    <#assign maxSelect = "1">
    <#include "../../common/dialog-newindustry.ftl" />
    </div>
    <div id="profession-dialog" style="display:none;">
    <#assign maxSelect = 5 >
    <#assign professionType = "radio">
    <#include "../../common/dialog-profession.ftl" />
    </div>
    <script type="text/javascript"> 
        $(function() {
            $('.J_cancel').click(function()
            {
                removeDialog('industry');
                removeDialog('profession');
            })
            var $checks = $('.J_check'),
                    $btnO = $('#J_practiceSubmit'),
                    flag = true;
            $checks.formValidate({button:'practiceValidate'});
            $checks.focus(function () 
            {
                $(this).parents('td.input').find('.error').hide();
                $(this).removeClass('textarea-error');
            }).click(function()
            		{
                        $(this).parents('td.input').find('.error').hide();;
                    });
            $('.text').focus(function()
            {
                $(this).parents('td.input').find('.error').hide();
            });

            $btnO.click(function (e) 
            { 
                e.preventDefault();
                var itemType = $(this).attr('itemtype');
                $checks.each(function () 
                {
                    var e = $.formValidate.check('practiceValidate',this);
                    if (!e) 
                    {
                        if(this.nodeName == 'TEXTAREA')
                        {
                            $(this).addClass('textarea-error')
                        }
                        $(this).parents('td.input').find('.error').show();
                        $(this).parents('td.input').find('.queryout').remove();
                    }
                });
                
                //alert("check.res:"+$.formValidate.check('practiceValidate'));
                if ($.formValidate.check('practiceValidate') ) 
                {
                    var startDate = $('#work-startdate-year').val() + '-';
                    if ($('#startdate-month').val().length == 1) 
                    {
                        startDate += '0';
                    }else if ($('#startdate-month').val().length == 0) 
                    {
                        startDate += '01';
                    }
                    startDate += $('#startdate-month').val()+"-01";
                    $('#id-startDate').val(startDate);
                    if ($('#enddate-present-checkbox').attr('checked')) 
                    {
                        $('#id-endDate').val('2030-01-01');
                    } else 
                    {
                        var endDate = $('#enddate-year').val() + '-';
                        if($('#enddate-month').val().length==1)
                        {
                            endDate+='0';
                        }else if ($('#enddate-month').val().length == 0) 
                        {
                            endDate += '01';
                        }
                        endDate+=$('#enddate-month').val()+"-01";
                        $('#id-endDate').val(endDate);
                    }
                    $checks.each(function()
                    {
                        var $this = $(this);
                        var bv = $this.attr('blankvalue');
                        if(bv && bv == $this.val())
                        {
                            $this.val('');
                        }
                    });
                    removeDialog('industry');
                    removeDialog('profession');
                    callback(itemType);
                }
            });
        });
        
        
    </script>
